<?php

// put full path to Smarty.class.php

$smartyPath = "/home/geeka813/Smarty-3.1.13/libs";
$publicHtml = "/home/geeka813/public_html";
$base_css = "/css";
$base_images = "/images";
$syntaxPath = "/syntaxhighlighter_3.0.83";

// contains all smarty declarations
require_once($publicHtml . '/config.php');

$log->LogInfo("Processing index page");

$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$menuSql = "SELECT data FROM page_item WHERE pageid=99";
  			
$result = $pdo->query($menuSql);
//# Map results to object
//$result->setFetchMode(PDO::FETCH_CLASS, 'pageid');
$results = $result->fetchAll(PDO::FETCH_ASSOC);   		
		
$carousel1 = array();
$menu1 = array();
$slider1 = array();

if(sizeof($results) > 0)
{
	foreach($results as $row)
	{
		if($row['data'] != "")
		{
			$dataObj = json_decode($row['data']);
			$log->LogInfo("Processing item dataObj = " . print_r($dataObj, TRUE));
			
			switch($dataObj->type)
			{
				case "carousel1":
				{
					$obj = new stdClass();
					
					$obj->url = $dataObj->url;
					$obj->posttype = $dataObj->posttype;
					$obj->title = $dataObj->title;
					$obj->description = $dataObj->description;
					
					$carousel1[] = $obj;
				}
				break;
				
				case "menu1":
				{
					$obj = new stdClass();
					
					$obj->name = $dataObj->name;
					$obj->submenus = $dataObj->submenus;
					
					$menu1[] = $obj;
				}
				break;
				
				case "slider1":
				{
					$obj = new stdClass();
					$obj->url = $dataObj->url;
					
					$slider1[] = $obj;
				}
				break;
				
			}
		}
	}
}

$log->LogInfo("carousel1 = " . print_r($carousel1, TRUE));
$log->LogInfo("menu1 = " . print_r($menu1, TRUE));

$smarty->assign("carousel1", $carousel1);
$smarty->assign("menu1", $menu1);
$smarty->assign("slider1", $slider1);
$smarty->assign("base_css", $base_css);
$smarty->assign("base_images", $base_images);
$smarty->assign("syntax_path", $syntaxPath);

$crumbTrail = array();
$crumbTrail["Home > "] = "index.php";
$crumbTrail["Code Things > "] = "swdev.php";
$crumbTrail["PHP Stuff"] = "";

$smarty->assign("crumbtrail", $crumbTrail);


$smarty->display('code_snippets.tpl');

?>